import { getInfo } from '@/services/user';
import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    user: {},
  },
  mutations: {
    setUser: (state, user) => {
      state.user = user;
    },
  },
  actions: {
    async getUser(context) {
      const { code, data } = await getInfo();
      //console.log(data);
      if (code == 200) context.commit('setUser', data);
    },
  },
  modules: {},
});
